package xcmg.device.web.warehouse;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import xcmg.device.infra.BasicController;
import xcmg.device.service.vo.warehouse.UpdatePrintNumVO;
import xcmg.device.service.vo.warehouse.WarehouseInboundDetailVO;
import xcmg.device.service.warehouse.WarehouseInboundDetailService;
import yb.ecp.fast.infra.annotation.FastMappingInfo;
import yb.ecp.fast.infra.infra.ActionResult;
import yb.ecp.fast.infra.infra.PageCommonVO;
import yb.ecp.fast.infra.infra.SearchCommonVO;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/warehouseInboundDetail")
public class WarehouseInboundDetailController extends BasicController{
    @Autowired
    private WarehouseInboundDetailService warehouseInboundDetailService;

    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @ApiOperation("查询入库详情列表")
    @FastMappingInfo(needLogin = true)
    public ActionResult listInboundNote(@RequestBody SearchCommonVO<WarehouseInboundDetailVO> condition)throws Exception{
        WarehouseInboundDetailVO warehouseInboundDetailVO =condition.getFilters();
        if(warehouseInboundDetailVO == null){
            warehouseInboundDetailVO = new WarehouseInboundDetailVO();
        }
        warehouseInboundDetailVO.setOrgId(getOrgId());
        condition.setFilters(warehouseInboundDetailVO);
        PageCommonVO pageCommonVO= warehouseInboundDetailService.list(condition);
        return actionValueResult(pageCommonVO.getPageInfo());
    }

    @RequestMapping(value = "/updatePrintNum",method = RequestMethod.POST)
    @ApiOperation(value = "根据非正常入库单号和零件号更新已打印条码数量")
    @FastMappingInfo(needLogin = true)
    public ActionResult warehouse(@RequestBody UpdatePrintNumVO updatePrintNumVO)throws Exception{
        List<UpdatePrintNumVO> list = new ArrayList<UpdatePrintNumVO>();
        list.add(updatePrintNumVO);
        return actionResult(warehouseInboundDetailService.updatePrintNum(list, getOrgId()));
    }
}
